<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
	<link href="../css/general.css" rel="stylesheet" type="text/css">
	<link href="../css/main.css" rel="stylesheet" type="text/css">
	<title></title>
</head>
<body>
	<h1>
		<span class="action-span"><a href="reportShow">当日数据统计</a></span>
		<span class="action-span1">结算数据统计 </span>
		<div style="clear:both"></div>
	</h1>
	<div class="form-div">
		<form action="" method="post">
		<div id="code">渠道选择：
			<select name="pipe_id" id="p">
			<option value="0">-全部渠道-</option>
			<c:forEach items="${pipes}" var="pipe">
				<c:if test="${pipe.id == pipe_id}"> <option value="${pipe.id}" selected="selected">${pipe.name} | ${pipe.cmd}</option></c:if>
				<c:if test="${pipe.id != pipe_id}"> <option value="${pipe.id}">${pipe.name} | ${pipe.cmd}</option></c:if>
			</c:forEach>

			</select>
			&nbsp;&nbsp; 开始时间： <input value="${start_at}" name="start_at" class="Wdate" type="text" onfocus="WdatePicker({skin:&#39;whyGreen&#39;})">
			&nbsp;&nbsp; 结束时间： <input value="${end_at}" name="end_at" class="Wdate" type="text" onfocus="WdatePicker({skin:&#39;whyGreen&#39;})">&nbsp;&nbsp; <input type="submit" value=" 查询 " class="button"></div>
		</form>
	</div>
	
	<div class="list-div" id="listDiv">
		<table cellpadding="3" cellspacing="1">
		  	<tbody><tr>
			  	<th>日期</th>
			    <th>推广渠道</th>
			  	<th>通道订购数(条)</th>
			    <th>同步订购数(条)</th>
			    <th>通道结算单价(元)</th>
			    <th>通道结算金额(元)</th>
			    <th>合作方支付单价(元)</th>
			    <th>合作方支付金额(元)</th>
			    <th>利润(元)</th>
			    <th>利润率</th>
			</tr>
<c:set var="orderCountSum" value="0" />
<c:set var="syncCountSum" value="0" />
<c:set var="orderTotalPriceSum" value="0" />
<c:set var="pipeTotalPriceSum" value="0" />
<c:set var="profitSum" value="0" />

<c:forEach items="${list}" var="sm">
	<c:set var="orderCountSum" value="${orderCountSum + sm.orderCount}" />
	<c:set var="syncCountSum" value="${syncCountSum + sm.syncCount}" />
	<c:set var="orderTotalPriceSum" value="${orderTotalPriceSum + sm.orderTotalPrice}" />
	<c:set var="pipeTotalPriceSum" value="${pipeTotalPriceSum + sm.pipeTotalPrice}" />
	<c:set var="profitSum" value="${profitSum + sm.profit}" />
	<tr>
		<td>${sm.moAt}</td>
		<td>${sm.pipeName}</td>
		<td>${sm.orderCount}</td>
		<td>${sm.syncCount}</td>
		<td>￥${sm.channelPrice/100}</td>
		<td>￥${sm.orderTotalPrice/100}</td>
		<td>￥${sm.pipePrice/100}</td>
		<td>￥${sm.pipeTotalPrice/100}</td>
		<td>￥${sm.profit/100}</td>
		<td><font color="red">
				<c:if test="${sm.orderTotalPrice == 0}"> 0% </c:if>
				<c:if test="${sm.orderTotalPrice != 0}">${sm.profit*100/sm.orderTotalPrice}% </c:if>
			</font></td>
	</tr>
</c:forEach>

			<tr>
				<th><b>合计</b></th>
				<th>-</th>
				<th><b>${orderCountSum}</b></th>
				<th><b>${syncCountSum}</b></th>
				<th>-</th>
				<th><b>￥${orderTotalPriceSum/100}</b></th>
				<th>-</th>
				<th><b>￥${pipeTotalPriceSum/100}</b></th>
				<th><b>￥${profitSum/100}</b></th>
				
				<th><b><font color="red">
					<c:if test="${orderTotalPriceSum == 0}"> 0% </c:if>
					<c:if test="${orderTotalPriceSum != 0}">${profitSum*100/orderTotalPriceSum}% </c:if>
						
						</font></b></th>
			</tr>
		</tbody></table>
	</div>

<div style="position: absolute; z-index: 19700; top: -1970px; left: -1970px; "></div></body>
</html>